<?php

namespace common\models;

use common\base\BaseBackendActiveRecord;
use yii\base\Model;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "order_car".
 *
 * @property int $id 自增
 * @property int $circuit_id 路线id
 * @property int $shift_id 班次ID
 * @property int $carpool_id 拼车班次ID
 * @property int $order_id 订单ID
 * @property int $car_id 车辆ID
 * @property int $inspector 检票员ID
 * @property int $status 状态：1：正常；0：停用；2：删除
 * @property int $addtime 添加时间
 * @property int $updatetime 更新时间
 */
class OrderCar extends BaseBackendActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'order_car';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['addtime','updatetime'], 'safe'],
            [['circuit_id', 'shift_id','carpool_id','order_id','car_id','inspector','status'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '自增',
            'circuit_id' => 'circuit_id',
            'shift_id' => 'shift_id',
            'carpool_id'=>'carpool_id',
            'order_id'=>'order_id',
            'car_id'=>'car_id',
            'inspector'=>'inspector',
            'addtime' => '创建时间',
            'updatetime' => '更新时间',
            'status'=>'状态'
        ];
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'addtime',// 自己根据数据库字段修改
                'updatedAtAttribute' => 'updatetime', // 自己根据数据库字段修改, // 自己根据数据库字段修改
                //'value'   => new Expression('NOW()'),
                'value'   => function(){return date('Y-m-d H:i:s',time());},
            ],
        ];
    }
}
